﻿Imports System.Web.UI
Imports System.Web.UI.WebControls
<TargetControlType(GetType(HtmlControls.HtmlTableRow)), TargetControlType(GetType(HtmlControls.HtmlTableCell))> _
Public Class Grilla
  Inherits System.Web.UI.ExtenderControl


  Private FilasValor As Integer
  Public Property Filas() As Integer
    Get
      Return FilasValor
    End Get
    Set(ByVal value As Integer)
      FilasValor = value
    End Set
  End Property

  Private IDDatosValor As String = String.Empty
  Public Property IDDatos() As String
    Get
      Return IDDatosValor
    End Get
    Set(ByVal value As String)
      IDDatosValor = value
    End Set
  End Property

  Private ControlCreadoValor As String = String.Empty
  Public Property ControlCreado() As String
    Get
      Return ControlCreadoValor
    End Get
    Set(ByVal value As String)
      ControlCreadoValor = value
    End Set
  End Property

  Private PoblandoValor As String = String.Empty
  Public Property Poblando() As String
    Get
      Return PoblandoValor
    End Get
    Set(ByVal value As String)
      PoblandoValor = value
    End Set
  End Property

  Private EncontradoValor As String = String.Empty
  Public Property Encontrado() As String
    Get
      Return EncontradoValor
    End Get
    Set(ByVal value As String)
      EncontradoValor = value
    End Set
  End Property

  Private ElegidoValor As String = String.Empty
  Public Property Elegido() As String
    Get
      Return ElegidoValor
    End Get
    Set(ByVal value As String)
      ElegidoValor = value
    End Set
  End Property

  Private SeleccionadoValor As String = String.Empty
  Public Property Seleccionado() As String
    Get
      Return SeleccionadoValor
    End Get
    Set(ByVal value As String)
      SeleccionadoValor = value
    End Set
  End Property

  Private IdCeldaScrollValor As String = String.Empty
  Public Property IdCeldaScroll() As String
    Get
      Return IdCeldaScrollValor
    End Get
    Set(ByVal value As String)
      IdCeldaScrollValor = value
    End Set
  End Property

  Private IdCeldaInfoValor As String = String.Empty
  Public Property IdCeldaInfo() As String
    Get
      Return IdCeldaInfoValor
    End Get
    Set(ByVal value As String)
      IdCeldaInfoValor = value
    End Set
  End Property




  Protected Overrides Function GetScriptDescriptors(ByVal targetControl As System.Web.UI.Control) As IEnumerable(Of ScriptDescriptor)
    Dim descriptor As New ScriptBehaviorDescriptor("MoniMisi2.Grilla", targetControl.ClientID)
    Dim descriptors As New List(Of ScriptDescriptor)
    Dim IdCeldainfo As String = ""
    If Me.IdCeldaInfo <> "" Then
      IdCeldainfo = CType(Funciones.EncontrarControl(Me.IdCeldaInfo, Me), System.Web.UI.Control).ClientID
    End If
    Dim IdCeldaScroll As String = ""
    If Me.IdCeldaScroll <> "" Then
      IdCeldaScroll = CType(Funciones.EncontrarControl(Me.IdCeldaScroll, Me), System.Web.UI.Control).ClientID
    End If

    descriptor.AddProperty("IDDatos", CType(Funciones.EncontrarControl(Me.IDDatos, Me), System.Web.UI.Control).ClientID)
    descriptor.AddProperty("Filas", Me.Filas)
    descriptor.AddProperty("CeldaScroll", IdCeldaScroll)
    descriptor.AddProperty("CeldaInfo", IdCeldainfo)
    If Not Me.ControlCreado = String.Empty Then
      descriptor.AddEvent("ControlCreado", Me.ControlCreado)
    End If
    If Not Me.Poblando = String.Empty Then
      descriptor.AddEvent("Poblando", Me.Poblando)
    End If
    If Not Me.Elegido = String.Empty Then
      descriptor.AddEvent("Elegido", Me.Elegido)
    End If
    If Not Me.Seleccionado = String.Empty Then
      descriptor.AddEvent("Seleccionado", Me.Seleccionado)
    End If
    If Not Me.Encontrado = String.Empty Then
      descriptor.AddEvent("Encontrado", Me.Encontrado)
    End If
    descriptors.Add(descriptor)
    Return descriptors
  End Function

  ' Generate the script reference
  Protected Overrides Function GetScriptReferences() As IEnumerable(Of ScriptReference)
    Dim scriptRef As New ScriptReference("MoniMisi2.Grilla.js", Funciones.NombreCompletoEnsamblado(Me.GetType, "MoniMisi2.Grilla"))
    Dim scriptRefs As New List(Of ScriptReference)
    scriptRef.NotifyScriptLoaded = False
    scriptRefs.Add(scriptRef)
    Return scriptRefs
  End Function

  Private Sub Grilla_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim IdTarget As String = CType(Funciones.EncontrarControl(Me.TargetControlID, Me), System.Web.UI.Control).ClientID
    Me.Page.ClientScript.RegisterStartupScript(Me.GetType(), Me.ClientID, "MoniMisi2.Grilla.prototype.Multiplicar(document.getElementById('" + IdTarget + "')," + Me.Filas.ToString.Trim + ");", True)
  End Sub
End Class



